# coding: utf-8
# Author: zhenda

from flask import g


def login_required(func):
    def wrapper(*args, **kwargs):
        if g.user_id:
            return func(*args, **kwargs)  # 如果登录，就继续执行
        else:
            return {'message': 'Invalid Token'}, 401
    return wrapper  # 装饰器，返回函数，排查半小时
